package com.gxa.community.admin.controller.cart;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gxa.community.admin.service.cart.AllGoodsService;
import com.gxa.community.core.pojo.bo.classification.GoodsInfoBo1;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/cart")
public class CartController {
    @Autowired
    private AllGoodsService allGoodsService;
    @Autowired
    private ObjectMapper objectMapper;

    @ApiOperation("获取所有商品")
    @GetMapping("/getallgoods")
    public String getAllGoods() throws JsonProcessingException {
        List<GoodsInfoBo1> goodsInfoBo1List = allGoodsService.list();
        String s = objectMapper.writeValueAsString(goodsInfoBo1List);
        return s;
    }
}
